from fastapi import FastAPI
from scheduler.tasks import print_sync, print_async
from scheduler.scheduler import start, add_interval_job, add_corn_job


app = FastAPI()


@app.on_event("startup")
async def startup_event():
    start()
    add_interval_job(print_sync, seconds=30, job_id="job_sync")
    add_interval_job(print_async, seconds=45, job_id="job_async")
    add_corn_job(print_sync, cron_expr="*/1 * * * *", job_id="job_cron")


@app.get("/")
async def index():
    return {"message":" FastAPI + APScheduler 启动成功"}
